*************************
* create variables book *
*************************
set more off    


use "Elites dataset book - raw.dta" // define path for your computer



* Code countries as in WVS
recode country 2=76 3=608 4=276 5=710 6=840 7=643 


* This is the dataset for some analyses in  Chapter 4 only:

save "\Elites six countries all GGIs.dta", replace




* coding missings

recode confgov 99=.
recode confUN 99=.
recode confIMF 99=.
recode confICC 99=.
recode confNATO 99=.
recode confWHO 99=.
recode confWB 99=.
recode confWTO 99=.
recode confUNFCCC 99=.
recode confUNSC 99=.
recode confG20 99=.
recode confICANN 99=.
recode confFSC 99=.
recode confKP 99=.
recode confFIFA 99=.
recode confAU 99=.
recode confEU 99=.
recode confASEAN 99=.
recode confNAFTA 99=.
recode confMERCOSUR 99=.
recode confSCO 99=.
recode knowUNSC 99=. 
recode knowIMF 99=.
recode knowamnesty 99=.
recode expUN 99=.
recode expIMF 99=.
recode expICC 99=.
recode expWB 99=.
recode expWHO 99=.
recode expWTO 99=.
recode pubconfgov  99=.
recode pubconfUN 99=.
recode pubconfIMF 99=.
recode pubconfICC 99=.
recode pubconfWB 99=.
recode pubconfWHO 99=.
recode pubconfWTO 99=.
recode feelcountry 99=.
recode feelworld 99=.
recode postmodfirst 99=.a
recode postmodsecond 99=.a
recode gentrust  99=.
recode leftright 99=.
recode finsathousehold 99=.
recode homo 99=.
recode abort 99=.
recode divorce 99=.
recode polsatisfaction 99=.
recode sex 99=.
recode yearbirth 99=.
recode area 99=.
recode Orientation 99=.
recode elitecat 99=.
recode education 99=.
recode sexmarriage 99=.
recode immigrants 99=.


sum ID country surveyyear confUN confIMF confICC confWB confWHO confWTO confNATO confUNFCCC confUNSC confICANN confKP confFSC confFIFA confG20 confSCO confAU confEU confASEAN confNAFTA confMERCOSUR knowUNSC knowIMF knowamnesty gentrust expUN expIMF expICC expWB expWHO expWTO pubconfgov pubconfUN pubconfIMF pubconfICC pubconfWB pubconfWHO pubconfWTO feelworld feelcountry postmodfirst postmodsecond homo abort divorce sexmarriage immigrants leftright yearbirth sex finsathousehold polsatisfaction education confgov  Orientation area elitecat 




* countries
tab country
label define countries 76 "Brazil" 608 "Philippines" 276 "Germany" 710 "South Africa" 840 "USA" 643 "Russia", modify
label values country countries
tab country



* define as elites ("resptype") vs. citizens for dyadic data Chapter 9
gen respondent = _n
summarize respondent
gen resptype = 2



* DV: confidence IOs
sum confUN-confWTO
recode confUN 1=0 2=1 3=2 4=3
recode confIMF 1=0 2=1 3=2 4=3
recode confICC 1=0 2=1 3=2 4=3
recode confWB 1=0 2=1 3=2 4=3
recode confWHO 1=0 2=1 3=2 4=3
recode confWTO 1=0 2=1 3=2 4=3

gen confios= (confICC+confIMF+confUN+confWB+confWHO+confWTO)/6
sum confios

* contextualization GGIs (Chapter 4)
recode confNATO 1=0 2=1 3=2 4=3
recode confUNFCCC 1=0 2=1 3=2 4=3
recode confUNSC 1=0 2=1 3=2 4=3
recode confICANN 1=0 2=1 3=2 4=3
recode confKP 1=0 2=1 3=2 4=3
recode confFSC 1=0 2=1 3=2 4=3
recode confFIFA 1=0 2=1 3=2 4=3
recode confG20 1=0 2=1 3=2 4=3

recode confSCO 1=0 2=1 3=2 4=3
recode confEU 1=0 2=1 3=2 4=3
recode confNAFTA 1=0 2=1 3=2 4=3
recode confMERCOSUR 1=0 2=1 3=2 4=3
recode confAU 1=0 2=1 3=2 4=3
recode confASEAN 1=0 2=1 3=2 4=3
recode confgov 1=0 2=1 3=2 4=3



replace confEU=. if country==6
replace confASEAN=. if country==6
replace confSCO=. if country==6
replace confMERCOSUR=. if country==6

gen confREGIO= confASEAN // this excludes South Africa as this country is excluded in this part of Chapter 4
replace confREGIO=0  if confEU==0
replace confREGIO=1  if confEU==1
replace confREGIO=2  if confEU==2
replace confREGIO=3  if confEU==3

replace confREGIO=0  if confNAFTA==0
replace confREGIO=1  if confNAFTA==1
replace confREGIO=2  if confNAFTA==2
replace confREGIO=3  if confNAFTA==3

replace confREGIO=0  if confSCO==0
replace confREGIO=1  if confSCO==1
replace confREGIO=2  if confSCO==2
replace confREGIO=3  if confSCO==3

replace confREGIO=0  if confMERCOSUR==0
replace confREGIO=1  if confMERCOSUR==1
replace confREGIO=2  if confMERCOSUR==2
replace confREGIO=3  if confMERCOSUR==3

tab confREGIO, missing
tab confREGIO if country==2
tab confMERCOSUR if country==2

save "\Elites six countries all GGIs.dta", replace





* This is the dataset for most analyses in Chapter 4, all analyses in Chapter 8, and as elite file to combine with citizens in Chapter 9 (i.e. without South Africa)

drop if country==710

save "\Elites five countries all GGIs.dta", replace


* IVs: socioeconomic status
***************************

* education
sum education

gen edu_3 = education
recode edu_3 0 1 2 3 4 5 6=1 7=2 8=3
tab edu_3


* satisfaction with the financial situation of one's household
sum finsathousehold
recode finsathousehold 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
sum finsathousehold

* IVs: political values
***********************

* left-right self-placement
sum leftright
recode leftright 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9

* GAL-TAN orientation
sum postmodfirst postmodsecond homo abort divorce sexmarriage immigrants

recode homo 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
recode abort 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
recode divorce 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
recode sexmarriage 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9
recode immigrants 1=0 2=1 3=2 4=3 5=4

gen ordernation1 = postmodfirst
recode ordernation1 2=0 3=0 4=0
tab ordernation1, missing

gen ordernation2 = postmodsecond
recode ordernation2 2=0 3=0 4=0
tab ordernation2, missing

gen comb_ordernation = ordernation1+ordernation2
tab comb_ordernation

gen comb_NOTordernation = comb_ordernation
recode comb_NOTordernation 1=0 0=1 // code 0 is people who prioritized order in the nation (first or second place), code 1 is those who prioritized something else

gen ethliberal = (homo+divorce+sexmarriage+abort)/4
sum ethliberal

gen TAN_GAL = ((ethliberal/9)+(immigrants/4)+(comb_NOTordernation))/3
sum TAN_GAL
mean TAN_GAL
* mean =0.6650414
hist TAN_GAL

gen GAL=1 if TAN_GAL>0.6650414
replace GAL=0 if TAN_GAL<0.6650414
replace GAL=. if TAN_GAL==.
tab GAL, missing





* IVs: geographical identification
**********************************

* global identification
sum feelworld
recode feelworld 1=0 2=1 3=2 4=3

* national identification
sum feelcountry 
recode feelcountry 1=0 2=1 3=2 4=3


* IVs: domestic institutional trust
***********************************

* confidence in government // see contextualization approx. line 130
* sum confgov
* recode confgov 1=0 2=1 3=2 4=3

* satisfaction with the political system of one's country
sum polsatisfaction
recode polsatisfaction 1=0 2=1 3=2 4=3 5=4 6=5 7=6 8=7 9=8 10=9


* IVs: professional characteristics
***********************************

* experience with IOs
sum  expUN expIMF expICC expWB expWHO expWTO 
recode expUN 1=0 2=1 3=2 4=3
recode expIMF 1=0 2=1 3=2 4=3
recode expICC 1=0 2=1 3=2 4=3
recode expWB 1=0 2=1 3=2 4=3
recode expWHO 1=0 2=1 3=2 4=3
recode expWTO 1=0 2=1 3=2 4=3

gen experience_IOs = (expUN +expIMF+ expICC +expWB +expWHO +expWTO)/6

* issue area
tab area

label define issueareas 1 "economy" 2 "human security" 3 "sustainable development" 4 "nothing specific (broad)" 5 "sports" 6 "internet" 8 "other specific"
label values area issueareas
tab area

gen area_4 = area
recode area_4 4 5 6 8=4
tab area_4
label values area_4 issueareas

* elite sector

label define sectors 1 "Partisan-political" 2 "Bureaucratic" 3 "Civil society" 4 "Media" 5 "Business" 6 "Research" 
label values elitecat sectors
tab elitecat

* governance level of orientation
tab Orientation
label define orientationlevel 1 "Subnational" 2 "National" 3 "International" 
label values Orientation orientationlevel
tab Orientation


* Controls
**********

* age
tab surveyyear
gen age = surveyyear-yearbirth
summarize age

* gender
sum sex
gen male = sex
recode male 2=0 3=0
tab male

* social trust
tab gentrust
recode gentrust 2=0

* knowledge about global governance

gen knUNSC_DK0 =knowUNSC
recode knUNSC_DK0 3=1  1 2 .=0 
tab knUNSC_DK0

gen knIMF_DK0 =knowIMF
recode knIMF_DK0 3 2 .=0 
tab knIMF_DK0

gen knAMN_DK0 =knowamnesty
recode knAMN_DK0 2=1  1 3 .=0 
tab knAMN_DK0

gen knowledge_DK0 = knUNSC_DK0+knIMF_DK0+knAMN_DK0
tab knowledge_DK0

gen know_all = knowledge_DK0
recode know_all 0 1 2=0 3=1
tab know_all



* Chapter 5: estimated confidence of public

sum pubconfgov  pubconfUN  pubconfIMF pubconfICC pubconfWB pubconfWHO pubconfWTO 

recode pubconfgov 1=0 2=1 3=2 4=3
recode pubconfUN 1=0 2=1 3=2 4=3
recode pubconfIMF 1=0 2=1 3=2 4=3
recode pubconfICC 1=0 2=1 3=2 4=3
recode pubconfWB 1=0 2=1 3=2 4=3
recode pubconfWHO 1=0 2=1 3=2 4=3
recode pubconfWTO 1=0 2=1 3=2 4=3


save "\Elites five countries all GGIs.dta", replace


